
/**
 * inspect obj whether a plain object.
 * @param {*} obj The object to inspect.
 * @returns True if the argument appears to be a plain object.
 */
export default function isPlainObject(obj) {
  // 不是对象、或者是null时，直接返回
  if (typeof obj !== 'object' || obj === null) {
    return false;
  }

  // 获取根原型
  let proto = obj
  while (Object.getPrototypeOf(proto) !== null) {
    proto = Object.getPrototypeOf(proto)
  }

  // 判断obj的原型和根原型是否相等
  return Object.getPrototypeOf(obj) === proto;
}